import { getUserInfo, setUserInfo, removeUserInfo } from './storage'
export default {
  namespaced: true,
  state () {
    return {
      userInfo: getUserInfo(),
      platform: 'H5'
    }
  },
  getters: {
    getPlatform: state => state.platform,
    getToken: state => state.userInfo.token
  },
  mutations: {
    setToken (state, obj) {
      setUserInfo(obj)
    },
    delToken () {
      removeUserInfo()
    }
  },
  actions: {
    setToken ({ commit }, {
      userId,
      token
    }) {
      commit('setToken', {
        userId,
        token
      })
    }
  }
}
